package com.cc.main.problems;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.cc.main.Const;
import com.cc.main.ICommonCmd;
import com.cc.main.cmd.AddKeywordCmd;
import com.cc.main.problems.bean.KeyWordItem;
import com.cc.main.problems.bean.ProblemBean;
import com.cc.main.util.CcExceeption;
import com.cc.main.util.MyUtils;

/**
 * 删除 关键的行
 * @author TR
 *
 */
public class DeleteKeyword implements ICommonCmd{

	private static List<KeyWordItem> keywordList = new ArrayList<>();
	static {
		keywordList.add(new KeyWordItem("uSDK    :"));
		keywordList.add(new KeyWordItem("js_domain_model:"));
	}

	@Override
	public void execute(Object action) throws CcExceeption {
		// TODO Auto-generated method stub
		ProblemBean bean = (ProblemBean) action;
		List<KeyWordItem> endlist = new ArrayList<>();
		endlist.addAll(keywordList);
		if(!bean.addkeyList.isEmpty()) {
			endlist.addAll(bean.addkeyList);
		}
		if(bean.logFileList.size() != 1) {
			throw new CcExceeption("该指令需要指定操作单个文件！"); 
		}
		try {
			List<String> result = MyUtils.deleteMsg(endlist,bean.logFileList.get(0));
			bean.result.addAll(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
